Public Class frmDISCOUNT

    Public BILL_TOTAL As Double
    Public LINE_TOTAL As Double
    Public DiscountPercent As Double


    Private Sub UpdateV(ByVal Value As Double)

        If ckLine_Percent.Checked Then
            If Value > 100 Then
                txtDiscountAmt.Text = ""
                txtDiscountPercent.Text = ""
                Return
            End If
            DiscountPercent = Value
            If ckLine_Amount.Checked Or ckLine_Percent.Checked Then
                txtDiscountAmt.Text = LINE_TOTAL * DiscountPercent / 100
            Else
                txtDiscountAmt.Text = BILL_TOTAL * DiscountPercent / 100
            End If
        ElseIf ckTotal_Percent.Checked Then
            If Value > 100 Then
                txtDiscountAmt.Text = ""
                txtDiscountPercent.Text = ""
                Return
            End If
            DiscountPercent = Value
            If ckLine_Amount.Checked Or ckLine_Percent.Checked Then
                txtDiscountAmt.Text = LINE_TOTAL * DiscountPercent / 100
            Else
                txtDiscountAmt.Text = BILL_TOTAL * DiscountPercent / 100
            End If
        ElseIf ckLine_Amount.Checked Then
            If Value > LINE_TOTAL Then
                txtDiscountAmt.Text = ""
                txtDiscountPercent.Text = ""
                Return
            End If
            DiscountPercent = Value * 100 / LINE_TOTAL
            txtDiscountPercent.Text = DiscountPercent
        ElseIf ckTotal_Amount.Checked Then
            If Value > BILL_TOTAL Then
                txtDiscountAmt.Text = ""
                txtDiscountPercent.Text = ""
                Return
            End If
            DiscountPercent = Value * 100 / BILL_TOTAL
            txtDiscountPercent.Text = DiscountPercent
        End If
    End Sub

    Private Sub UiButton9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UiButton9.Click, UiButton8.Click, UiButton7.Click, UiButton6.Click, UiButton5.Click, UiButton4.Click, UiButton39.Click, UiButton3.Click, UiButton2.Click, UiButton11.Click, UiButton10.Click, UiButton1.Click
        If ckLine_Amount.Checked Or ckTotal_Amount.Checked Then
            txtDiscountAmt.Text = txtDiscountAmt.Text & CType(sender, Janus.Windows.EditControls.UIButton).Text
            UpdateV(CDbl(txtDiscountAmt.Text))
        Else
            txtDiscountPercent.Text = txtDiscountPercent.Text & CType(sender, Janus.Windows.EditControls.UIButton).Text
            UpdateV(CDbl(txtDiscountPercent.Text))
        End If
    End Sub


    Private Sub frmDISCOUNT_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Try
            GC.Collect()
            Me.Dispose()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub frmDISCOUNT_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        PublicFunction.NewFormLoad(Me)
    End Sub
End Class